/**
 * Created by Ryze on 16/3/15.
 */
define(function(require) {

    var utils = require("utils");

    var thisPlugins={};


    //保存登录用户
    thisPlugins.saveConnectUser = function(json){
        utils.saveItem("Connect_User",utils.json2string(json));
    }
    //获得登录用户
    thisPlugins.getConnectUser = function(){
        if(!utils.getItem("Connect_User")){
            return "";
        }
        return utils.string2json(utils.getItem("Connect_User"));
    }


    //保存登录用户
    thisPlugins.saveLoginUser = function(json){
        utils.saveItem("Login_User",utils.json2string(json));
    }
    //获得登录用户
    thisPlugins.getLoginUser = function(){
        if(!utils.getItem("Login_User")){
            return false;
        }
      return utils.string2json(utils.getItem("Login_User"));
    }

    thisPlugins.removeLoginUser = function(){
        utils.saveItem("Login_User","");
    }

    thisPlugins.isLogined = function(){
        if (!this.getLoginUser()) {
            window.location.href = "login.html";
        }
    }

    return thisPlugins;
});
